<style scoped src="./index.scss" lang="scss" rel="stylesheet/scss"></style>
<template src="./index.html"></template>
<script>
export default {
  mixins: [Vue.prototype.$vFN.Mixins.Base],
  components: {},
  data() {
    return {
      appWindow: window,
      // 页面接口地址
      apiUrl: {
          otherSettings: "mall-site-portal/platform-setting/getSettingItem",
          updateOther: "mall-site-portal/platform-setting/saveOrUpdate",
      },
      load: false,

      // 其他设置表单
      otherForm: {
        customerUrl: "", //客服链接
        mapKey: "", //地图api
      },

    };
  },
  methods: {
    // 初始化
    async init() {
      this.load = true;
      this.getOtherSet();
      this.load = false;
    },

       // 获取其他设置
    async getOtherSet() {
      let res = await this.$vFN.Http.post(
        {
          url: this.apiUrl.otherSettings,
        },
        window
      );
      if (res._ok) {
        for (const key in this.otherForm) {
          if (!this.$vFN.Utils.isEmpty(res.data[key])) {
            this.otherForm[key] = res.data[key];
          }
        }
      }
    },

   //保存
   async updateOther() {
    let res = await this.$vFN.Http.post(
        {
          url: this.apiUrl.updateOther,
          data: {
            ...this.otherForm,
          },
        },
        window
      );

      if (res._ok) {
        this.$vFN.Tools.messageSuccess(res.message);
        this.init();
      }
    },

  },
  mounted() {
    this.init();
  },

  activated() {},
};
</script>
